#! /usr/bin/env python
# -*- coding: utf8 -*

# Alexandre Coster <acoster@rhrk.uni-kl.de>
# AG DBIS - Technische Universität Kaiserslautern
# This program takes the output of xXML applications and shows the ammount of error

from sys import argv

for fn in argv[1:]:
    print "Filename: %s " % (fn, )

    fp = open(fn, "r")
    l = fp.readlines()
    fp.close()
    
    print "%d subtrees" % (len(l),)
    
    errors = 0
    chars  = 0
    
    for i in l:
        s = [int(x) for x in i.split()]
        chars  += s[0]
        errors += s[1]
    
    print "Chars:  %d" % (chars,)
    print "Errors: %d" % (errors,)
    print "Ratio:  %f" % (float(errors) / chars)
    print ""
